using System.Data;
using TelerikMvcGridCustomBindingHelper.ORMIntegration;

namespace TelerikMvcGridCustomBindingHelper.Mapper
{
    public interface IFluentORMIntegrationConfiguration
    {
        void UseTransactions(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, TransactionBehavior behavior = TransactionBehavior.BeginAndCommit);
        void UseTransactions(TransactionBehavior behavior);
    }

    public class FluentORMIntegrationConfiguration : IFluentORMIntegrationConfiguration
    {
        public void UseTransactions(IsolationLevel isolationLevel = IsolationLevel.ReadCommitted, TransactionBehavior behavior = TransactionBehavior.BeginAndCommit)
        {
            ORMIntegrationHolder.TransactionIsolationLevel = isolationLevel;
            ORMIntegrationHolder.TransactionBehavior = behavior;
        }

        public void UseTransactions(TransactionBehavior behavior)
        {
            ORMIntegrationHolder.TransactionIsolationLevel = IsolationLevel.ReadCommitted;
            ORMIntegrationHolder.TransactionBehavior = behavior;
        }
    }
}